/**
@author		Jong Min, Lee
@date		  10/01/2014
@breif		instance class 

copyright(c) Tae Young Soft. All right reserved. 2014
*/
#pragma once

#include <vector>
#include "Taurus_Util/Macros.h"
#include "Taurus_DcmData/Defines.h"

//forward declarations
class CDcmInstance;
class CSeries;
class CFrame;

/**
@brief		instance class for displaying
*/
class TAURUS_DCMDATA_EXPORT CInstance
{
private:
  /**
  @brief		default constructor
  */
  CInstance();

  DISALLOW_COPY_AND_ASSIGN(CInstance);

public:
  friend class CInstanceProducer;

  /**
  @brief		destructor
  */
  ~CInstance();

  /**
  @brief		access to parent instance
  @return		pointer to parent series if instance has it, NULL if not
  */
  inline CSeries* getParent() const
  {
    return m_theParent;
  }

  /**
  @brief		set the parent instance
  @param		parent pointer to instance to be parent
  */
  inline void setParent(CSeries* parent)
  {
    m_theParent = parent;
  }

  /**
  @brief		access to SOP Class UID
  @return		null terminated string represents sop class uid
  */
  const TCHAR* getSOPClassUID() const;

private:
  /**
  @brief		initialize instance
  */
  void init();

  /**
  @brief		destroy instance. this function should be only used in destructor
  */
  void destroy();

  /**
  @brief		remove all frames
  */
  void removeAllFrames();

private:
  //pointer to parent series
  CSeries* m_theParent;

  //pointer to dicom instance
  CDcmInstance* m_theDcmInstance;

  //frames
  std::vector<CFrame*> m_theFrames;
};

/**
@brief		instance producer class
*/
class TAURUS_DCMDATA_EXPORT CInstanceProducer
{
public:
  /**
  @brief		create new instance
  @param		dcmInstance pointer to dcm instance to be based
  @param    parent pointer to series to be parent
  @param    outInstance variable in which new instance is stored
  @return		
  */
  static DWORD produce(CDcmInstance* dcmInstance,
                       CSeries* parent,
                       CInstance*& outInstance);
};